package com.lee.treasure.component.redis.config;

import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;

/**
 * @author Lee
 * @date 2020/8/6
 */
public abstract class BaseRedisConfig {

    /**
     * 创建redis连接工厂
     *
     */
    public LettuceConnectionFactory createConnectionFactory(int dbIndex, String host, int port, String password) {
        RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(host, port);
        configuration.setDatabase(dbIndex);
        configuration.setPassword(password);

        return new LettuceConnectionFactory(configuration);
    }
}
